package com.webRepo.spiderUtil;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ListPageProcessor implements ValueProcessor<Matcher> {

    //所有url的前缀
    private static final String BASEURL = "http://www.xiamp4.com";
    
    public void processor(Matcher matcher, ArrayBlockingQueue<String> queue) {
        if(matcher==null){
            return;
        }
        while (matcher.find()) {
            String urlResult = matcher.group();
            String contentUrl = urlResult.split("\"")[3];
            String name = urlResult.split("\"")[5];
            queue.add(BASEURL+contentUrl);
            System.out.println(Thread.currentThread().getName()+"获取:"+contentUrl+"==>"+name);
        }
    }

    public Matcher matchTactics(String value, String match) {
        Pattern compile = Pattern.compile(match);
        if(compile==null){
            return null;
        }
        return compile.matcher(value);
    }


}
